package com.yzl.frelink.entities.dep;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import lombok.Data;

@Data
public class Demap {
    Set<String> reqs;
    Set<String> vars;
    Set<String> modes;
    List<Deedge> edges;

    public Demap() {
        this.reqs = new HashSet<>();
        this.vars = new HashSet<>();
        this.modes = new HashSet<>();
        this.edges = new ArrayList<>();
    }

    public void addReq(String req) {
        this.reqs.add(req);
    }
    
    public void addVar(String var) {
        this.vars.add(var);
    }

    public void addEdge(String source, String target) {
        this.edges.add(new Deedge(source, target));
    }

    public void addMode(String mode) {
        this.modes.add(mode);
    }

    public List<String> getEntryStates() {
        List<String> firstStates = new ArrayList<>(this.modes);
        for (Deedge edge : this.edges) {
            firstStates.remove(edge.getTarget());
        }
        return firstStates;
    }
}
